﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H


#include "opencv2/opencv.hpp"
#include <imgtransition.h>

#include <QMainWindow>
#include <QWidget>
#include <QLabel>
#include <QScrollArea>

#include <QImage>

#include <QMap>
#include <QList>

namespace Ui {
class MainWindow;
}

class Dialog;

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:

    void init();

    void init_show();

    void init_connect();
    
    void load_image(QString url);

    void clear_map();
    void clear_img_show_list();

    void add_img_to_lab(QLabel* lab,QImage& img);

    void add_to_map(QString key, QImage img);

    void chage_tab_widget_size();

    void clear_show();

    void add_show();

    void resizeEvent(QResizeEvent *event);

    void count_chip(cv::Mat &mat,int &upper_line,int &lower_line);

    void count_cutline(cv::Mat &mat,int up_chip,int low_chip,int &up_line,int &low_line);

    void paint_chip(cv::Mat &show,cv::Mat &cut_line,int up_chip,int low_chip,int up_line,int low_line);




private slots:

    void slot_openfile();

    void slot_change_threshold_value();


private:
    Ui::MainWindow *ui;

    Dialog *dialog;

    QMap<QString,QWidget*> img_widget;
    QList<QScrollArea*>    show_aear;
    QMap<QString,QLabel*> img_show;
    QMap<QString,QImage>  img_map;

    QImage m_image;

    QString current_path;

    int mainwindows_width;
    int mainwindows_heigth;

    int threshold_value;
    int center_offset;
    int open_operation;


};

#endif // MAINWINDOW_H
